<%@ page language="java" import="com.bjsxt.shopping.user.*,java.sql.SQLException" pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>

<%
	request.setCharacterEncoding("utf-8");
String action = request.getParameter("action");

System.out.println(action);
if(action != null && action.trim().equals("register")) {
	
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		//String password2 = request.getParameter("password2");
		String phone = request.getParameter("phone");
		String addr = request.getParameter("addr");
		
		String tests = request.getParameter("cst");
		String testsTrans = request.getParameter("cstyw");
		
		
		
		User u = new User();
		u.setUsername(username.trim());
		u.setPassword(password.trim());
		u.setPhone(phone);
		u.setAddr(addr);
		u.setRdate(new Date());
		u.setStatus("0");
		u.setAcctype("2");
		//测试题
		u.setTests(tests);
		u.setTestsTrans(testsTrans);
		
		u.setTranslatorLevel("0");
		
		boolean resSucc=  u.save();
		
		if (resSucc) {
			u.setLoginname(username);
			session.setAttribute("user", u);
			System.out.println(u.getLoginname());
			out.println("注册资料已提交，请等待管理员审核通过!");
			return;
		} else {
			out.println("出现错误，未成功注册，请联系管理员!");
			return;
		}
	}
%>

<html><head><title>众译快翻--译者注册</title>


<script type="text/javascript">
	var req;
	
	function trim(t){
		return (t||"").replace(/^\s+|\s+$/g, "");
	}
		
	function  userNameExistCheck() {
		//用户名必须输入
		var username = register.username.value;  
		if(null==username||trim(username)==""){
			alert('用户名不能为空!');
			register.action.value="noPass";
			register.username.focus();		
			return false;
		}	
	
		//存在性
		var url = "ValidateResTransor.jsp?id=" + escape(username);
		if(window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.open("GET", url, true);
		req.onreadystatechange = callbackUserExist;
		req.send(null);
	}
	
	function callbackUserExist() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				var msg0 = req.responseXML.getElementsByTagName("msg")[0];
		        var msg =msg0.childNodes[0].nodeValue;
		        
				mdiv = document.getElementById("usermsg");
				if(msg == "invalid") {
					mdiv.innerHTML = "<font color='red'>该用户名已经存在！</font>";
				} else {
					mdiv.innerHTML = "<font color='green'>你可以使用这个用户名!</font>";
				}		        
		        
			}
		}
	}
	
	function validate() {
		//用户名必须输入
		var username = register.username.value;  
		if(null==username||trim(username)==""){
			alert('用户名不能为空!');
			register.action.value="noPass";
			register.username.focus();		
			return false;
		}
		
		var  index = escape(username).indexOf("%u");
        if(index == 0){  
			alert('用户名不能包含汉字!');
			register.action.value="noPass";
			register.username.focus();		
			return false;     	
     	}		    		
	
		//用户名重复
		mdiv = document.getElementById("usermsg");
		var strDivMsg= mdiv.innerHTML;
		if(strDivMsg.indexOf("已经存在") >= 0){
			alert('该用户名已经存在!');
			register.action.value="noPass";
			register.username.focus();		
			return false;
		}
	
		var password = register.password.value;  
		if(null==password||password==""){
			alert('密码不能为空!');
			register.action.value="noPass";
			register.password.focus();
			return false;
		}
	
		
		var password2 = register.password2.value;  
		var password = register.password.value; 
		if(null==password2||password2==""||password2!=password){
			alert('两次输入密码不一致!');
			register.action.value="noPass";
			register.password2.focus();
			return false;
		}

		//译文必须输入
		var cstyw = register.cstyw.value;  
		if(null==cstyw||trim(cstyw)==""){
			alert('译文不能为空!');
			register.action.value="noPass";
			register.cstyw.focus();		
			return false;
		}		
		
		register.action.value="register";	
		
	}

</script>


<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,">
<meta name="description" content="专区  - Discuz! Board">
<meta name="generator" content="Discuz! 4.0.0RC4 with Templates 4.0.0">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="MSThemeCompatible" content="Yes">

<style type="text/css"><!--
a			{ text-decoration: none; color: #000000 }
a:hover			{ text-decoration: underline }
body			{ scrollbar-base-color: #F3F6FA; scrollbar-arrow-color: #4D76B3; font-size: 12px; background-color: #ffffff }
table			{ font: 12px Verdana,Tahoma; color: #000000 }
input,select,textarea	{ font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }
select			{ font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }
.nav			{ font: 12px Verdana,Tahoma; color: #000000; font-weight: bold }
.nav a			{ color: #000000 }
.header			{ font: 11px Verdana,Tahoma; color: #FFFFFF; font-weight: bold; background-image: url("images/green/bg01.gif") }
.header a		{ color: #FFFFFF }
.category		{ font: 11px Verdana,Tahoma; color: #000000; background-color: #EFEFEF }
.tableborder		{ background: #4D76B3; border: 0px solid #4D76B3 } 
.singleborder		{ font-size: 0px; line-height: 0px; padding: 0px; background-color: #F3F6FA }
.smalltxt		{ font: 11px Verdana,Tahoma }
.outertxt		{ font: 12px Verdana,Tahoma; color: #000000 }
.outertxt a		{ color: #000000 }
.bold			{ font-weight: bold }
.altbg1			{ background: #F3F6FA }
.altbg2			{ background: #FFFFFF }
--></style><script language="JavaScript" src="images/common.js"></script><style type="text/css" id="defaultPopStyle">.cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}</style></head><body leftmargin="0" rightmargin="0" topmargin="0" onkeydown="if(event.keyCode==27) return false;"><div id="popLayer" style="position: absolute; z-index: 1000;" class="cPopText"></div>
</head>

<table id="table1" align="center" border="0" cellpadding="0" cellspacing="0" width="97%">
  <tbody>
  <tr valign="top">
    <td style="border-top: 0px none; border-right: 1px none; font-size: 9pt; font-family: Tahoma,Verdana; color: rgb(0, 0, 0);" width="100%"><table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tbody><tr>
        <td bgcolor="#4d76b3" height="20">&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#4e6793" height="2"></td>
      </tr>
      <tr>
        <td background="images/bitmap.gif" height="80" valign="middle"><table align="right" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td valign="middle" width="5">&nbsp;</td>
            <td valign="middle" width="157"><div align="left"><a href="thinkshop.cn.htm" target="_blank"><br></a></div></td>
            <td valign="middle" width="812"><div align="right">
              <a style="left: 799px ! important; top: 61px ! important;" class="abp-objtab visible" href="http://www.allsmart.com/images/new1.swf"></a>                 

            </div></td>
            <td width="5">&nbsp;</td>
          </tr>
        </tbody></table></td>
      </tr>
      <tr>
        <td><table id="table3" bgcolor="#f3f6fa" cellpadding="3" cellspacing="0" width="100%">
          <tbody>
            <tr>
              <td style="border-top: 0px none; border-right: 1px none; font-size: 9pt; font-family: Tahoma,Verdana; color: rgb(0, 0, 0);" bgcolor="#f3f6fa" height="20"><font style="line-height: normal;" color="#000000"><a href="faq.php.htm"><br></a> </font></td>
              <td width="225"><table align="right" border="0" cellpadding="0" cellspacing="0" width="225">
                <tbody><tr>
                  <td width="75"><a href="index.php.htm"><br></a></td>
                  <td width="75"><a href="brandshop.php.htm" target="_blank"><br></a></td>
                  <td width="75"><a href="powered by Discuz!.htm" target="_blank"><br></a></td>
                  </tr>
              </tbody></table>
             </td>
              </tr>
            <tr bgcolor="#4d76b3">
              <td colspan="2" height="1"> </td>
            </tr>
            <tr bgcolor="#ffffff">
              <td colspan="2" height="5"></td>
            </tr>
          </tbody>
        </table></td>
      </tr>
    </tbody></table>
</td>
    </tr></tbody></table>
<table style="table-layout: fixed;" align="center" border="0" cellpadding="0" cellspacing="0" width="97%"> 
<tbody><tr><td class="nav" align="left" nowrap="nowrap" width="90%">众译快翻--译者注册</td>
<td align="right" width="10%">&nbsp;<a href="#bottom"><img src="images/arrow_dw.gif" align="absmiddle" border="0"></a></td>        
</tr></tbody></table><br>

<form method="post" name="register" action="" onSubmit="this.regsubmit.disabled=true;">
<input type="hidden" name="action" value="register"/>

<table class="tableborder" align="center" cellpadding="4" cellspacing="1" width="97%">
<tbody><tr>
<td colspan="3" class="header">众译快翻-译者注册</td>
</tr>
<tr>
<td class="altbg1" rowspan="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   </td>
<td class="altbg1" width="21%">译者用户名:</td> 
<td class="altbg2"><input id="userid" name="username" size="32" maxlength="30" type="text"  onblur="userNameExistCheck()"> 
<span id="usermsg"></span>
</tr>

<tr>
<td class="altbg1">密码:</td>
<td class="altbg2"><input name="password" size="16" maxlength="16" type="password" ></td>
</tr><tr>
<td class="altbg1">确认密码:</td>
<td class="altbg2"><input name="password2" size="16" maxlength="16" type="password"></td>
</tr>

<tr>
<td class="altbg1">联系方式:</td>
<td class="altbg2"><input name="phone" type="text" id="phone" size="25"></td>
</tr>

<tr>
<td class="altbg1">测试题:</td>
<td class="altbg2" colspan="2"><textarea name="cst"  style="width: 98%;height: 60px;resize: none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;国内外贸易，产品研发，转口贸易等方式的经营项目，拥有自己的贸易业务和强大的产品研发技术力量，致力于智能产品的研发、生产、国内外销售、物流配送、售后服务。 
     生产pp编织袋再生颗粒和Eps再生颗粒的大型塑料造粒，月产量1000吨。 经营安防产品、智能家居产品、数码产品、电脑周边等；</textarea></td>
</tr>
<tr>
<td class="altbg1">请在下面填入测试题译文:</td>
<td class="altbg2" colspan="2"><textarea name="cstyw"  style="width: 98%;height: 80px;resize: none;"></textarea></td>
</tr>

</tbody></table>
<br>
<center><input name="regsubmit" value="提 &nbsp; 交" type="submit" onclick="return validate(this.form)"></center>
</form>

<script language="JavaScript">
document.register.username.focus();
</script>

<p align="center">　</p>
<table class="smalltxt" cellpadding="4" cellspacing="0" width="100%">
<tbody><tr class="altbg1"><td></td>
<td align="right"> </td>
<td align="right" width="1">&nbsp;</td>
</tr>
<tr style="padding: 0px; font-size: 0px; line-height: 0px;" images="" green="" bg01.gif="" )=""><td colspan="3">　</td></tr>
</tbody></table>
<p align="center">

<br>
<a name="bottom"></a>

<a target="_blank" href="/Register.jsp"><u>众译快翻</u></a><br>
服务热线:0991-4621130
<!--<br><font color=#ebebeb>
Powered by <a href="http://www.discuz.net" target="_blank"><font color=#ebebeb>Discuz!</font></a> 
<a href="misc.php?action=viewlicense"><b style="color:#ebebeb">4.0.0RC4</b></a>&nbsp;
&copy; 2001-2005 <a href="http://www.comsenz.com" target="_blank"><font color=#ebebeb>Comsenz Technology Ltd</font></a>
<br>Processed in 0.011754 second(s), 5 queries
-->
</p>
</body></html>